<template>
	<view class="waterfall-block" :id="'select_' + dataItem.id">
		<view class="waterfall-item" @click="jumpDetail(dataItem.id)">
			<view class="waterfall-item__pic">
				<image class="img" :src="dataItem.litpic" mode="widthFix" @load="loadImage($event, dataItem.id)" @error="errorImage($event, dataItem.id)"></image>
				<view class="glance"><text class="iconfont">&#xe652;</text>{{dataItem.shownum}}</view>
			</view>
			<view class="waterfall-item__info">
				<view class="title">{{dataItem.title}}</view>
				<view class="author" v-if="dataItem.member">
					<view class="lc">
						<image class="icon" :src="dataItem.member.litpic" mode="aspectFill"></image>
						<view class="act">
							<view class="name">{{dataItem.member.nickname}}</view>
							<view class="date">{{dataItem.addtime}}</view>
						</view>
					</view>
					<view class="rc" v-if="dataItem.favorite > 0"><text class="iconfont">&#xe702;</text>{{dataItem.favorite}}</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name:"st-waterfall-flow-item",
		props: {
			dataItem: {
				type: Object,
				default(){
					return {}
				}
			}
		},
		data() {
			return {
				
			};
		},
		methods: {
			loadImage(e, id){
				const query = uni.createSelectorQuery().in(this)
				query.select('#select_' + id).boundingClientRect(data => {
					let height = Math.floor(data.height)
					this.$emit('loadHeight', {id, height})
				}).exec()
			},
			errorImage(e, id){
				this.$emit('loadHeight', {id, height: 155})
			},
			// 跳转详情
			jumpDetail(id){
				uni.navigateTo({
					url: `/subPackages/note/detail?id=${id}`
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
.waterfall-block{
	padding: 10rpx;
}
.waterfall-item{
	padding: 16rpx;
	position: relative;
	overflow: hidden;
	border-radius: 16rpx;
	background-color: $uni-bg-color;
	&__pic{
		width: 100%;
		position: relative;
		overflow: hidden;
		border-radius: 16rpx;
		.img{
			width: 310rpx !important;
			height: 310rpx !important;
		}
		.glance{
			color: #fff;
			position: absolute;
			padding: 40rpx 20rpx 20rpx;
			left: 0;
			right: 0;
			bottom: 0;
			text-align: right;
			font-size: 24rpx;
			background: linear-gradient(to bottom, transparent, rgba(0,0,0, .8));
			.iconfont{
				vertical-align: middle;
				margin: -6rpx 8rpx 0 0;
				font-size: 28rpx;
			}
		}
	}
	&__info{
		width: 100%;
		padding: 12rpx 0 0;
		.title{
			width: 300rpx;
			line-height: 36rpx;
			font-size: 26rpx;
		}
		.glance{
			color: $uni-text-color-deep;
			margin-bottom: 24rpx;
			font-size: $uni-font-size-mini;
		}
		.author{
			display: flex;
			justify-content: space-between;
			align-items: center;
			margin-top: 20rpx;
			.lc{
				flex: 1 1 auto;
				display: flex;
				.icon{
					flex: 0 0 auto;
					width: 56rpx;
					height: 56rpx;
					border-radius: $uni-border-radius-circle;
				}
				.act{
					margin-left: 12rpx;
					.name{
						white-space: nowrap;
						font-size: $uni-font-size-sm;
						overflow: hidden;
						text-overflow: ellipsis;
						width: 162rpx;
					}
					.date{
						color: $uni-text-color-deep;
						width: 200%;
						margin-top: -22rpx;
						transform: scale(.5);
						transform-origin: left bottom;
						font-size: 40rpx;
						font-family: Arial, Helvetica, sans-serif;
					}
				}
			}
			.rc{
				.iconfont{
					margin-right: 6rpx;
					font-size: 28rpx;
				}
				flex: 0 0 auto;
				font-size: 26rpx;
				font-family: Arial, Helvetica, sans-serif;
				text-align: right;
			}
		}
	}
}
</style>